#!/usr/bin/env python
# encoding: utf-8
# @author: Lin Han
# @contact: voldemort22@126.com
# @file: update_scene.py
# @time: 2021/4/27 14:30
# @desc:
from .utils.mongo_tools import retrieve_all_mongo_values, update_mongo_value
from .views.configs import MONGO_DATABASE_NAME, SCENE_COLLECTION

result = retrieve_all_mongo_values(
    {},
    database_name=MONGO_DATABASE_NAME,
    collection_name=SCENE_COLLECTION,
)

for i in result:
    try:
        if i["standardClamp"] is None:
            i["standardClamp"] = []
    except KeyError:
        i["standardClamp"] = []


for i in result:
    updateInfo = {"$set": i}
    update_mongo_value(
        filter_condition={"number": i["number"]},
        new_value=updateInfo,
        database_name=MONGO_DATABASE_NAME,
        collection_name=SCENE_COLLECTION,
    )

